package com.lineage.server.model.skill.skillmode;

import com.lineage.server.model.Instance.L1NpcInstance;
import com.lineage.server.model.Instance.L1PcInstance;
import com.lineage.server.model.L1Character;
import com.lineage.server.model.L1Magic;
import com.lineage.server.serverpackets.S_Paralysis;
import com.lineage.server.serverpackets.ServerBasePacket;
import com.lineage.server.utils.L1SpawnUtil;
import java.util.Random;

public class BONE_BREAK extends SkillMode {
  private static Random _random = new Random();
  
  public int start(L1PcInstance srcpc, L1Character cha, L1Magic magic, int integer) throws Exception {
    int dmg = magic.calcMagicDamage(208);
    if (cha.hasSkillEffect(208))
      return dmg; 
    int time = _random.nextInt(2) + 1;
    cha.setSkillEffect(208, time * 1000);
    L1SpawnUtil.spawnEffect(86123, time, cha.getX(), cha.getY(), cha.getMapId(), cha, 0);
    if (cha instanceof L1PcInstance) {
      L1PcInstance pc = (L1PcInstance)cha;
      pc.sendPackets((ServerBasePacket)new S_Paralysis(5, true));
    } else if (cha instanceof com.lineage.server.model.Instance.L1MonsterInstance || cha instanceof com.lineage.server.model.Instance.L1SummonInstance || 
      cha instanceof com.lineage.server.model.Instance.L1PetInstance) {
      L1NpcInstance npc = (L1NpcInstance)cha;
      npc.setParalyzed(true);
    } 
    return dmg;
  }
  
  public int start(L1NpcInstance npc, L1Character cha, L1Magic magic, int integer) throws Exception {
    int dmg = 0;
    return 0;
  }
  
  public void start(L1PcInstance srcpc, Object obj) throws Exception {}
  
  public void stop(L1Character cha) throws Exception {
    if (cha instanceof L1PcInstance) {
      L1PcInstance pc = (L1PcInstance)cha;
      pc.sendPackets((ServerBasePacket)new S_Paralysis(5, false));
    } else if (cha instanceof com.lineage.server.model.Instance.L1MonsterInstance || cha instanceof com.lineage.server.model.Instance.L1SummonInstance || 
      cha instanceof com.lineage.server.model.Instance.L1PetInstance) {
      L1NpcInstance npc = (L1NpcInstance)cha;
      npc.setParalyzed(false);
    } 
  }
}
